<?php

	/*
	 * If you want to check the performance, use these soureces below and end of line.
	 *
	 */
	//$st = explode(" ", microtime());


	/*
	 *	URL Information, not contain protocols(http://, https://).
	 *
	 */

	$home_addr = "localhost";

	/*
	 *	Core folder default path. you want to move, change this value.
	 *
	 */

	$system_path = "system";


	/*
	 *	App folder default path. you want to move, change this value.
	 *
	 */

	$app_path = "application";

	define("__DEBUG__", false);

/*
 		#  #  #   ##  #   #  ###   #   #
	 	# ## #   # #  ##  #  #  #  #   #    Wandu Start, Don't Touch!
	 	## ##   ####  # # #  #  #  #   #      Developed by Wani.(me@wani.kr)
	 	#  #   #   #  #  ##  ###    ###
*/

	if( version_compare(PHP_VERSION,'5.2.0') < 0 ) 
		exit('Wandu requires at least PHP version of 5.2.0. Sorry cannot continue.');

	define("__WD__", true);

	define("__ROOT__", realpath("."));
	define("__APP__", realpath($app_path));
	define("__SYSTEM__", realpath($system_path));

	define("HOME", $home_addr );
	define("SELF", $home_addr.(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : "") );

	define("PATH", ltrim((!isset($_SERVER['PATH_INFO']) || $_SERVER['PATH_INFO'] == "") ? "." : $_SERVER['PATH_INFO'] ,"/") );


	unset($home_addr, $app_path, $system_path);

	require_once( __SYSTEM__."/core/functions.php" );
	require_once( __SYSTEM__."/core/wandu.php" );
	require_once( __APP__."/controller/__router.php" );

	$RTR = null; // Router
	$ERR = null; // Error Handler

	$RTR = &getInstance("__Router");
	$ERR = &getInstance("__Error");
	
	ob_start();
	
	set_error_handler(array($ERR, "callNormal"));
	set_exception_handler( array($ERR, 'callException' ) );
	register_shutdown_function( array($ERR, 'callShutdown' ) );
	
	$path = explode("/", trim(PATH, "/"));
	
	$RTR->doit($path);
	
	$ERR->show();
	/*
	 * If you want to check the performance, use this.
	 *
	 */
	//$et = explode(" ", microtime());echo "<script>console.log(\"".( ( $et[1]- $st[1])+( $et[0]-$st[0] ) )."\");</script>" ;



